<template>
  <!-- 移除原有布局，直接渲染登录组件 -->
  <router-view></router-view>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import axios from 'axios'
const router = useRouter()

// 初始化时根据登录状态跳转
const token = localStorage.getItem('token')
if (token) {
    axios.get('/auth/validate', {
    headers: { Authorization: `Bearer ${token}` }
  }).catch(() => {
    // Token 无效或过期时清理并跳转
    localStorage.clear();
    router.push('/login');
  });
  router.push(localStorage.getItem('role') === 'ADMIN' ? '/admin/dashboard' : '/user/dashboard')
} else {
  router.push('/login')
}
</script>

<style scoped>
/* 保留必要的全局样式 */
.app-container {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
}
</style>